package com.itheima.youdianda.controller;

import com.itheima.youdianda.common.R;
import com.itheima.youdianda.pojo.SysRole;
import com.itheima.youdianda.pojo.SysUser;
import com.itheima.youdianda.service.SysUserService;
import com.itheima.youdianda.vo.SysUserVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("sys_user")
@Slf4j
public class SysUserController {
    @Autowired
    private SysUserService sysUserService;

    @GetMapping("list")  //todo:传参支持模糊查询?phone,status参数值为?
    public R list(@RequestParam("login_name") String loginName, String status, String phone, int page, int limit){
        log.info("传参{}",loginName);
       return sysUserService.listSysUser(loginName, status, phone, page, limit);
    }

    @GetMapping("del")  //GET 角色删除
    public R delete(String id){
        sysUserService.delete(id);
        return R.success(null);
    }

    @PostMapping("add")  //todo:POST 角色添加,id没处理
    public R add(@RequestBody SysUserVo vo){
        sysUserService.add(vo);
        return R.success(null);
    }

    @GetMapping("rowInfo")  //GET 角色详情
    public R rowInfo(String id){
        return sysUserService.rowInfo(id);
    }

    @PostMapping("update") //POST 角色修改
    public R update(@RequestBody SysUserVo vo){
        sysUserService.updateSysRole(vo);
        return R.success(null);
    }










}
